﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ZedGraph;
using System.IO;

namespace PermonAnalizer
{
    public partial class Main : Form
    {

        private List<String> perfmonFiles;

        public Main()
        {
            InitializeComponent();
            CPUGraph cpu = new CPUGraph(zedGraphControlCPU, new List<DataPoint>() );
            cpu.CreateCPUGraph();
        }

        private void testToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void testToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
  
        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult result = folderBrowserDialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                string[] rawFiles = Directory.GetFiles( folderBrowserDialog.SelectedPath);
                List<String> filterFiles = new List<string>();
                for (int i = 0; i < rawFiles.Length; i++ ){
                    if( rawFiles[i].Contains("PerfMon") &&  rawFiles[i].Contains("csv")){
                        filterFiles.Add(rawFiles[i]);
                        System.Diagnostics.Debug.WriteLine("DEBUG: Opened File " + rawFiles[i] );
                    }
                }
                PerfmonLoader loader = new PerfmonLoader();
                loader.ReadPerfmonLog( zedGraphControlCPU, filterFiles);
                stripLabelFiles.Text = "Files Analyzed: " + filterFiles.Count;
                perfmonFiles = filterFiles;
            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Environment.Exit( 0 );
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}
